package com.yijiu.trb;

import android.graphics.PixelFormat;
import android.os.Bundle;
import android.widget.TextView;

import com.yijiu.action.BaseAction;
import com.yijiu.network.Request;
import com.yijiu.resource.ActionType;
import com.yijiu.resource.C;
import com.yijiu.resource.CacheData;
import com.yijiu.response.RequestClientDetailInfoResponse;

/**
 * 账户基本信息
 * 
 * @author TangChao
 */
public class UserBaseInfoActivity extends BTitleActivity
{
	/**
	 * 帐户名
	 */
	private TextView accountName;

	/**
	 * 余额
	 */
	private TextView balance;

	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		getWindow().setFormat(PixelFormat.RGBA_8888);
		setContentView(R.layout.activity_user_base_info);
		String appKey = CacheData.APP_KEY;
		requestClientDetailInfo(appKey);
		initWidget();
	}

	@Override
	protected void initWidget()
	{
		super.initWidget();
		titleView.setText("用户基本信息");
		accountName = (TextView) findViewById(R.id.tv_user_base_info_name);
		balance = (TextView) findViewById(R.id.tv_user_base_info_money);
		balance.setText(CacheData.AVAILABLE_BALANCE);
		accountName.setText(CacheData.REAL_NAME);
	}

	/**
	 * 客户详情请求
	 */
	private void requestClientDetailInfo(String appKey)
	{
		String inputStr = "service=appInvestorInfoService&userBaseId=" + appKey;
		encryptBase(inputStr, C.PRIVATE_KEY);
		BaseAction action = new BaseAction(encodedData, encriptData, appKey);
		RequestClientDetailInfoResponse requestClientDetailInfoResponse = new RequestClientDetailInfoResponse();
		Request request = new Request(action, requestClientDetailInfoResponse, ActionType.REQUEST_CLIENT_DETAIL_INFO);
		netManager.excute(request, this, this);
		showProgress("正在获取客户详情");
	}

	/**
	 * 操作成功返回的函数
	 */
	@Override
	public void getResult(Request r)
	{
		super.getResult(r);
		switch (r.getType())
		{
		// 请求客户详情
			case ActionType.REQUEST_CLIENT_DETAIL_INFO:
				break;
		}
	}

	/**
	 * 操作失败返回的函数
	 */
	@Override
	public void notifyError(int type, int errorCode, String errorMsg)
	{
		super.notifyError(type, errorCode, errorMsg);
		switch (type)
		{
			case ActionType.REQUEST_CLIENT_DETAIL_INFO:
				app.showMsg(errorMsg);
				break;
		}
	}

	/* 重复提交返回的函数 */
	@Override
	public void rePost(Request r)
	{
		super.rePost(r);
	}
}
